#ifndef H265TRANSH264_TRANSTHREAD_H
#define H265TRANSH264_TRANSTHREAD_H
/**
 * 转码操作线程
 */
#include <functional>
#include <utility>
#include "Extension/Frame.h"
#include "Thread/threadgroup.h"
#include "Thread/semaphore.h"
#include "h265_trans_h264.h"
#include "EasyBuff.h"

using namespace toolkit;
using namespace mediakit;
typedef std::function<void(uint8_t* bout, uint outsize,uint32_t pts, uint32_t dts, int hasKeyFrame)> onTransFrameCB;

class TransThread {
    public:
        typedef std::shared_ptr<TransThread> Ptr;
        TransThread(onTransFrameCB cbTransFrame);
         ~TransThread();
        void start();
        void wait();
        void PushFrame(const Frame::Ptr &frame_in);
    private: 
        void run();
    private:  
        thread_group _thread_group;
        //video 转码
        bool _bVideoTransCode;
        EasyH265Trans_Handle _pVideohandle = nullptr;
        //bool _bOpenTransCode;
//         char  _videobuf[EASY_MAX_FRAME_LEN];
        mutable mutex  _frameCachedMtx;
        std::list<Frame::Ptr> _frameCached;
        semaphore _sem;
        onTransFrameCB     _cbTransFrame = nullptr;
};
#endif
